package es.mfp.practicos.util;

import java.io.IOException;
import java.util.Map;

import net.sf.jasperreports.engine.JRAbstractExporter;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRPdfExporter;

/**
 * Clase de utilidades para jasperreports, en principio, para generar los
 * diferentes tipos de exportadores de diferentes mecanismos
 */
public class JasperReportsUtils {

	public static final String RUTA_LOGO = "/resources/images/logo.png";

	public final static String RUTA_JASPER = "/resources/reports/jasper/";

	public final static String RUTA_SUPREPORTS_JASPER = RUTA_JASPER;

	public final static String FORMATO_PDF = "PDF";

	public final static String MIME_TYPE_PDF = "application/pdf";

	public static JRAbstractExporter getPdfExporter(String jasperPath,
			Map<String, Object> params, JRDataSource jrdataSource)
			throws JRException, IOException {

		final JasperPrint jasperPrint = JasperFillManager.fillReport(
				jasperPath, params, jrdataSource);
		final JRPdfExporter exporter = new JRPdfExporter();

		exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

		return exporter;

	}

	private JasperReportsUtils() {

	}

}